<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css">
    <script src="../plugins/jquery/jquery.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../plugins/layui/layui.js"></script>
</head>
<body>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 280px;height: 230px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <center><h4 class="modal-title" id="myModalLabel">处理委派订单</h4></center>
            </div>
           <center>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
               &nbsp;  &nbsp;  &nbsp;  &nbsp;
                <button type="button" class="btn btn-primary" id="clbut">处理</button>
           </center>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<table class="table" id="tab">
  <tr>
    <td>委派编号</td>
    <td>申请人姓名</td>
    <td>申请类容</td>
    <td>联系电话</td>
    <td>委派时间</td>
    <td>操作/处理</td>
  </tr>
</table>
<script>
    /**
     * 刷新界面
     */
    function  ff(){
        window.location.href="cf.html"
    }

    /**
     * 手动开启模态框
     */
    function cl(wpbh){
        $('#myModal').modal('show');
        $("#clbut").on("click",function (){
            $.ajax({
                url:"cfxgbxzt",
                type: "post",
                data:{"wpbh":wpbh},
                success:function (data){
                    if(data){
                        $.ajax({
                            url:"shanchuwpdd",
                            type: "post",
                            data:{"wpbh":wpbh},
                            success:function(data1){
                                if(data1){
                                    layer.msg('处理成功', {icon: 6});
                                    setTimeout("ff()","1100");

                                }else {
                                    layer.msg('处理失败', {icon: 2});
                                    setTimeout("ff()","1100");
                                }
                            }
                        })
                    }else {
                        layer.msg('处理失败', {icon: 2});
                        setTimeout("ff()","1100");
                    }
                }

            })
        })
    }


    $.ajax({
        url:"wpxx",
        type:"post",
        success:function (data){
                console.log(data)
             for (let i=0;i<data.length;i++){

                 let sj=data[i]

                 let newtr=$("<tr>")

                 let td1=$("<td>")
                 td1.html(sj.wpbh)

                 let td2=$("<td>")
                 td2.html(sj.sqrname)

                 let td3=$("<td>")
                 td3.html(sj.sqlr)

                 let td4=$("<td>")
                 td4.html(sj.lxdh)

                 let td5=$("<td>")
                 td5.html(sj.wpsj)

                 let td6=$("<td>")
                 let but=$("<button>")
                 but.attr("class","btn btn-info")
                 but.attr("onclick",'cl('+sj.wpbh+')')

                 let sp=$("<span>")
                 sp.attr("class","glyphicon glyphicon-pencil")
                 but.html(sp)

                 td6.html(but)

                 newtr.append(td1,td2,td3,td4,td5,td6)

                 $("#tab").append(newtr)

             }
        }
    })
</script>
</body>
</html>